/*    */ package cc.s2m.web.s2mBlog.controller.admin;
/*    */ 
/*    */ import cc.s2m.web.s2mBlog.controller.base.BaseController;
/*    */ import cc.s2m.web.s2mBlog.pojo.Idcreater;
/*    */ import cc.s2m.web.s2mBlog.service.IIdcreater;
/*    */ import java.util.HashMap;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.ui.Model;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.bind.annotation.RequestParam;
/*    */ import org.springframework.web.bind.annotation.ResponseBody;
/*    */ 
/*    */ @Controller("admin_IdcreaterController")
/*    */ @RequestMapping({"/admin/idcreater"})
/*    */ public class IdcreaterController extends BaseController
/*    */ {
/*    */ 
/*    */   @Autowired
/*    */   private IIdcreater idcreaterService;
/*    */ 
/*    */   @RequestMapping(value={"/list"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String list(Model model)
/*    */   {
/* 32 */     List list = this.idcreaterService.getList(new Idcreater(), null);
/* 33 */     model.addAttribute("list", list);
/*    */ 
/* 35 */     return "admin/idcreater";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/add"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String add(@RequestParam(required=false) Integer id, Model model)
/*    */   {
/* 41 */     if (id != null) {
/* 42 */       Idcreater bean = (Idcreater)this.idcreaterService.selectByPrimaryKey(id);
/* 43 */       model.addAttribute("bean", bean);
/*    */     }
/* 45 */     return "admin/idcreater_add";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/save"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   @ResponseBody
/*    */   public String save(HttpServletRequest request, HttpServletResponse response, @RequestParam(required=false) Integer id, @RequestParam(required=false) String name, @RequestParam(required=false) Long value)
/*    */   {
/* 55 */     if ((name == null) || (name.getBytes().length > 2)) {
/* 56 */       return "nameError";
/*    */     }
/* 58 */     Idcreater bean = new Idcreater();
/* 59 */     if (id != null) {
/* 60 */       bean = (Idcreater)this.idcreaterService.selectByPrimaryKey(id);
/*    */     }
/* 62 */     Idcreater bean_ = this.idcreaterService.getByName(name);
/* 63 */     if ((bean_ != null) && (!bean_.getId().equals(bean.getId()))) {
/* 64 */       bean_ = null;
/* 65 */       return "exist";
/*    */     }
/* 67 */     bean_ = null;
/*    */ 
/* 69 */     if (id == null) {
/* 70 */       bean.setName(name);
/* 71 */       bean.setValue(value);
/* 72 */       this.idcreaterService.insert(bean);
/*    */     } else {
/* 74 */       Map map = new HashMap();
/* 75 */       map.put("name", bean.getName());
/* 76 */       map.put("valueOld", bean.getValue());
/* 77 */       map.put("value", value);
/* 78 */       this.idcreaterService.updateValues(map);
/*    */     }
/* 80 */     return "success";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   @ResponseBody
/*    */   public String del(HttpServletRequest request, HttpServletResponse response, @RequestParam(required=false) Integer id)
/*    */   {
/* 88 */     Idcreater bean = (Idcreater)this.idcreaterService.selectByPrimaryKey(id);
/* 89 */     if (bean != null) {
/* 90 */       this.idcreaterService.deleteByPrimaryKey(id);
/*    */     }
/* 92 */     return "success";
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.controller.admin.IdcreaterController
 * JD-Core Version:    0.6.1
 */